package com.alone.embedded.lucene.exception;

import lombok.experimental.UtilityClass;

import java.util.Objects;

/**
 * @author Alone
 * @date 2022/8/9 10:18 上午
 */
@UtilityClass
public class ElAssert {

    public void isNull(Object target, String message) {
        if (Objects.nonNull(target)) {
            throw EmbeddedLuceneException.of(message);
        }
    }

    public void nonNull(Object target, String message) {
        if (Objects.isNull(target)) {
            throw EmbeddedLuceneException.of(message);
        }
    }

    public void isTrue(boolean target, String message) {
        if (!target) {
            throw EmbeddedLuceneException.of(message);
        }
    }

    public void isFalse(boolean target, String message) {
        if (target) {
            throw EmbeddedLuceneException.of(message);
        }
    }

}
